<template>
  <div v-if="columns?.length > 0">
    <van-sticky :offset-top="45">
      <van-tabs v-model="columnId" >
        <van-tab
          :title="column.name"
          :name="column.id"
          v-for="(column, idx) in columns"
          :key="idx"
        ></van-tab>
      </van-tabs>
    </van-sticky>
    <MArticleList v-if="columnId" :columnId="columnId" />
  </div>
</template>

<script>
/*
  
*/ 
import { Notify } from "vant";
import MArticleList from "@/mviews/MArticleList";
export default {
  name: "VueEleMColumns",
  components: {
    MArticleList,
  },
  data() {
    return {
      columnId: "",
      columns: [],
      
    };
  },
  created() {
    this.getColumns();
  },
  mounted() {},

  methods: {
    async getColumns() {
      try {
        let result = await this.$http({ type: "columns" });
        this.columns = result.data.list;
        this.columnId = this.columns[0].id;
      } catch (err) {
        Notify({ type: "danger", message: "分类未找到" });
      }
    },
    // columnChange(name) {

    // }
  },
};
</script>